﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class StReg : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (this.TextBox1.Text == "" || this.TextBox2.Text == "" || this.TextBox3.Text == "" || this.TextBox5.Text == "")
        {
            Response.Write("<script>alert('输入信息不完整');</script>");
        }
        else
        {
            if (this.TextBox2.Text == this.TextBox3.Text)
            {
                string sql;
                sql = "select * from allusers where username='" + this.TextBox1.Text + "'";
                DataSet ds = new Class1().hsggetdata(sql);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    Response.Write("<script>javascript:alert('改用户已经存在！');</script>");
                }
                else
                {
                    sql = "insert into allusers(username,pwd,cx,性别,年龄,邮箱,QQ) values('" + TextBox1.Text.Trim() + "','" + this.TextBox2.Text + "','会员','" + this.DropDownList1.Text + "','" + this.TextBox5.Text + "','"  + this.TextBox7.Text + "','"  + this.TextBox8.Text + "')";
                    int result;
                    result = new Class1().hsgexucute(sql);
                    if (result == 1)
                    {
                        Response.Write("<script>javascript:alert('添加成功');window.navigate('login.aspx');</script>");
                    }
                    else
                    {
                        Response.Write("<script>javascript:alert('系统错误，您没有设置好数据库的连接！');</script>");
                    }
                }
            }
            else
            {
                Response.Write("<script>javascript:alert('两次输入的密码不一致！');</script>");
            }
        }
    }
}
